import java.util.Map;
import java.util.HashMap;
import java.util.Arrays;


public class TwoSum {
    public int[] twoSum(int[] nums, int target) {
        Map<Integer, Integer> map = new HashMap<Integer, Integer>();
        for(int size = 0; size < nums.length; size++) {
            int other = target - nums[size];
            if(map.containsKey(other)) {
                // return new int[]{map.get(other), size};
                return new int[]{size, map.get(other)};
            }
            map.put(nums[size], size);
        }

        return new int[0];

    }


    public static void main(String[] args) {
        TwoSum twoSum = new TwoSum();


        int[] test1 = new int[]{2, 7, 11, 15};
        int target1 = 9;
        int[] result1 = twoSum.twoSum(test1, target1);
        System.out.println(" result1:" + Arrays.toString(result1));


    }


}